<style scoped lang="scss">
.dl1 {
    display: flex;
}

.content {
    width: 90%;
    height: calc(100vh - 50px);
    margin: auto;

    // background: #ccc;
    dl {
        height: 50px;
        border-bottom: 1px solid #ccc;

        dd {
            line-height: 20px;
            padding-left: 10px;
        }
    }
}

.delete-button {
    height: 100%;
}
</style>
<template>
    <div>
        <!-- 使用头部组件 -->
        <homeTop :showspan4="true"></homeTop>
        <div class="content">
            <van-swipe-cell v-for="(item, index) in consultationData" :key="index">
                <dl class="dl1" @click="onchat(item.userId, item.inquiryTime)">
                    <dt>
                        <!-- <img style="width: 30px;height: 30px;border-radius: 50%;" :src="item.doctorHeadPic" alt=""> -->
                         <Image  style="width: 30px;height: 30px;border-radius: 50%;" :dataSrc="item.doctorHeadPic" ></Image>
                    </dt>
                    <dd>
                        <h4>{{ item.nickName }}</h4>
                        <p>123</p>
                    </dd>
                </dl>
                <template #right>
                    <van-button square text="取消" type="danger" class="delete-button" @click="onend(item.recordId)" />
                </template>
            </van-swipe-cell>
        </div>

    </div>
</template>
<script setup lang="ts">
// 引入头部组件
import homeTop from '@/components/homeTop/index.vue'
// 引入接口
import { getConsultationlist, getEnd } from '@/api/homeapi/index'
import { reactive, ref } from 'vue';
import { useRouter } from 'vue-router';
import Image from '@/components/image/index.vue'
const router = useRouter()
// 获取医生id和sessionId
const doctorId:any = localStorage.getItem('doctorId')
const sessionId = JSON.parse(localStorage.getItem('sessionId') as string)
// 定义接口recordId
const recordId = ref(1)
// 定义接口page
const page = ref(1)
// 定义接口count
const count = ref(5)
// 定义一个对象
const config = reactive({
    recordId: recordId,
    page: page,
    count: count
})
const consultationData:any = ref([])
const getListData = () => {
    getConsultationlist(doctorId, sessionId, config).then(res => {
        console.log(res);
        consultationData.value = res.data.result
    })
}
getListData()
const onchat = (userId: any, inquiryTime: any) => {
    console.log(userId);
    router.push({
        path: '/dialoguechat',
        query: {
            userId: userId,
            inquiryTime: inquiryTime
        }
    })
}

const onend = (recordId: any) => {
    console.log(recordId);
    getEnd(doctorId, sessionId, recordId).then(res => {
        console.log(res);
    })
    getListData()
}
</script>